import 'package:cbec_app/components/base/base_function.dart';
import 'package:cbec_app/components/base/base_interactive.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/utils/logger.dart';
import 'package:flutter/material.dart';
class TextNavItem extends StatefulWidget {
  ///菜单文字
  final String text;

  ///自身索引
  final int index;

  ///激活的索引
  final int? curIndex;

  ///点击时的回调
  final CallBackIndex? onClick;

  ///文本类菜单item
  const TextNavItem({
    super.key,
    required this.text,
    required this.index,
    this.curIndex = 0,
    this.onClick
  });

 
  
  @override
  State<StatefulWidget> createState()=>_TextNavItemState();
}
class _TextNavItemState extends State<TextNavItem>{
 @override
  Widget build(BuildContext context) {
    return BaseInteractive(
      childWidget: Text(
        widget.text!,
        style: TextStyle(
            fontSize: widget.curIndex == widget.index ? 15 : 14,
            fontWeight: widget.curIndex == widget.index ? FontWeight.w700 : FontWeight.w300,
            color: Colors.white,
            decoration: textNoDecoration()),
      ),
      onClick: () {
        logger.d('点击 自己${widget.index} 激活${widget.curIndex}');
        widget.onClick!(widget.index);
      },
    );
  }
}
